
import java.io.IOException;
import javax.microedition.lcdui.Image;

public class L {

    public static Image getImage(String path) {
        Image result = null;
        try {
            result = Image.createImage(path);
        } catch (IOException localIOException) {
        }
        return result;
    }

    public static boolean isInRect(int px, int py, int x, int y, int w, int h) {
        boolean isIn = true;
        if ((px < x) || (py < y) || (px > x + w) || (py > y + h)) {
            isIn = false;
        }
        return isIn;
    }

    public static Image effect_resizeImage(Image src, int destW, int destH) {
        int srcW = src.getWidth();
        int srcH = src.getHeight();

        int[] destPixels = new int[destW * destH];

        int[] srcPixels = getPixels(src);

        for (int destY = 0; destY < destH; destY++) {
            for (int destX = 0; destX < destW; destX++) {
                int srcX = destX * srcW / destW;
                int srcY = destY * srcH / destH;
                destPixels[(destX + destY * destW)] = srcPixels[
           (srcX + srcY
                        * srcW)];
            }
        }

        return drawPixels(destPixels, destW, destH);
    }

    public static int[] getPixels(Image src) {
        int w = src.getWidth();
        int h = src.getHeight();
        int[] pixels = new int[w * h];
        src.getRGB(pixels, 0, w, 0, 0, w, h);
        return pixels;
    }

    public static Image drawPixels(int[] pixels, int w, int h) {
        Image image = Image.createRGBImage(pixels, w, h, true);
        pixels = (int[]) null;
        return image;
    }
}
